<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>超英电竞 - 专业陪玩服务</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/viewerjs/1.11.6/viewer.min.css">
    <style>
        :root {
            --primary: #ff6b6b;
            --primary-light: #ff8e8e;
            --primary-dark: #ff4757;
            --secondary: #48dbfb;
            --secondary-light: #74f2ff;
            --accent: #ff9ff3;
            --accent-light: #fd79a8;
            --dark: #2c2c54;
            --dark-light: #40407a;
            --light: #ffffff;
            --gray: #a4b0be;
            --success: #1dd1a1;
            --card-bg: rgba(255, 255, 255, 0.95);
            --card-border: rgba(255, 107, 107, 0.2);
            --background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            -webkit-tap-highlight-color: transparent;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
            background: var(--background);
            color: var(--dark);
            line-height: 1.6;
            min-height: 100vh;
            padding: 0;
            overflow-x: hidden;
        }

        /* 顶部固定区域 - 优化样式 */
        .fixed-header {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 1000;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(20px);
            border-bottom: 1px solid rgba(255, 107, 107, 0.3);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            height: 100px; /* 减小高度 */
        }

        /* 公告栏 - 更现代的设计 */
        .announcement-bar {
            padding: 8px 20px; /* 减小内边距 */
            background: linear-gradient(90deg,
            rgba(255, 107, 107, 0.25),
            rgba(72, 219, 251, 0.25),
            rgba(255, 107, 107, 0.25));
            position: relative;
            overflow: hidden;
            color: var(--dark);
        }

        .announcement-bar::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.4),
            transparent);
            animation: shimmer 3s infinite;
        }

        @keyframes shimmer {
            0% { left: -100%; }
            100% { left: 100%; }
        }

        .announcement-content {
            display: flex;
            align-items: center;
            white-space: nowrap;
            animation: scrollAnnouncement 25s linear infinite;
            font-size: 0.85rem; /* 减小字体大小 */
            font-weight: 500;
        }

        @keyframes scrollAnnouncement {
            0% { transform: translateX(100%); }
            100% { transform: translateX(-100%); }
        }

        /* 俱乐部标识 - 更精致的样式 */
        .club-header {
            padding: 12px 20px; /* 减小内边距 */
            display: flex;
            align-items: center;
            gap: 12px; /* 减小间距 */
            background: rgba(255, 255, 255, 0.8);
        }

        .club-logo {
            width: 40px; /* 减小尺寸 */
            height: 40px;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.4rem; /* 减小字体大小 */
            box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
            transition: transform 0.3s ease;
            overflow: hidden;
        }

        .club-logo:hover {
            transform: rotate(10deg);
        }

        .club-name {
            font-weight: bold;
            font-size: 1.2rem; /* 减小字体大小 */
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            text-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
        }

        /* 主容器 - 左右布局 */
        .main-container {
            display: flex;
            min-height: 100vh;
            padding-top: 100px; /* 减小顶部间距 */
        }

        /* 左侧分类导航 - 固定不滚动 */
        .category-sidebar {
            width: 30%;
            max-width: 110px;
            background: rgba(255, 255, 255, 0.9);
            border-right: 1px solid rgba(255, 107, 107, 0.2);
            overflow-y: auto;
            padding: 20px 12px;
            backdrop-filter: blur(10px);
            position: sticky; /* 固定定位 */
            top: 100px; /* 与顶部固定区域高度一致 */
            height: calc(100vh - 100px); /* 视口高度减去顶部区域高度 */
            z-index: 100;
        }

        .category-item {
            display: block;
            padding: 14px 10px;
            margin-bottom: 10px;
            border-radius: 12px;
            transition: all 0.3s ease;
            cursor: pointer;
            font-size: 0.85rem;
            text-align: center;
            line-height: 1.3;
            font-weight: 500;
            background: rgba(255, 255, 255, 0.8);
            border: 1px solid rgba(255, 107, 107, 0.2);
            color: var(--dark);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        }

        .category-item:hover {
            background: rgba(255, 107, 107, 0.2);
            color: var(--dark);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(255, 107, 107, 0.2);
        }

        .category-item.active {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            border-color: transparent;
            box-shadow: 0 5px 20px rgba(255, 107, 107, 0.4);
            color: white;
            font-weight: 600;
        }

        /* 右侧产品区域 - 更现代的卡片设计 */
        .product-area {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
            background: rgba(255, 255, 255, 0.5);
        }

        .product-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 20px;
        }

        .product-card {
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: 18px;
            padding: 20px;
            transition: all 0.3s ease;
            backdrop-filter: blur(15px);
            position: relative;
            overflow: hidden;
            animation: fadeIn 0.5s ease-out;
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .product-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 2px;
            background: linear-gradient(90deg, var(--primary), var(--secondary));
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .product-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 35px rgba(255, 107, 107, 0.2);
            border-color: rgba(255, 107, 107, 0.4);
        }

        .product-card:hover::before {
            opacity: 1;
        }

        .product-card:active {
            transform: translateY(-2px);
        }

        .product-image {
            width: 100%;
            height: 160px;
            border-radius: 14px;
            margin-bottom: 16px;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
            position: relative;
            cursor: pointer; /* 添加指针样式 */
        }

        .product-image::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 40%;
            background: linear-gradient(to top, rgba(0, 0, 0, 0.1), transparent);
        }

        .product-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.5s ease;
        }

        .product-card:hover .product-image img {
            transform: scale(1.05);
        }

        .product-image i {
            font-size: 2.5rem;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .product-title {
            font-size: 1.1rem;
            font-weight: 700;
            margin-bottom: 8px;
            color: var(--dark);
            line-height: 1.3;
        }

        .product-desc {
            color: var(--dark-light);
            font-size: 0.9rem;
            margin-bottom: 16px;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            line-height: 1.5;
        }

        .product-meta {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .price-container {
            display: flex;
            flex-direction: column;
        }

        .product-price {
            font-size: 1.3rem;
            font-weight: 800;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            line-height: 1;
        }

        .product-unit {
            font-size: 0.85rem;
            color: var(--dark-light);
            margin-top: 2px;
        }

        .product-btn {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            border: none;
            border-radius: 10px;
            padding: 10px 20px;
            color: white;
            font-size: 0.9rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
            display: flex;
            align-items: center;
            gap: 5px;
        }

        .product-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
            background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
        }

        .product-btn:active {
            transform: translateY(0);
        }

        /* 详情模态框 - 更精美的设计 */
        .detail-modal .modal-dialog {
            margin: 30px auto;
            max-width: 90%;
            max-width: 400px;
        }

        .detail-modal .modal-content {
            background: rgba(255, 255, 255, 0.98);
            backdrop-filter: blur(25px);
            border: 1px solid rgba(255, 107, 107, 0.4);
            border-radius: 20px;
            color: var(--dark);
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
        }

        .detail-modal .modal-header {
            border-bottom: 1px solid rgba(255, 107, 107, 0.3);
            padding: 20px;
            background: linear-gradient(90deg,
            rgba(255, 107, 107, 0.1),
            rgba(72, 219, 251, 0.1));
        }

        .detail-modal .modal-title {
            font-size: 1.3rem;
            font-weight: 700;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .detail-modal .modal-body {
            padding: 25px;
        }

        .detail-image {
            width: 100%;
            height: 180px;
            border-radius: 16px;
            margin-bottom: 20px;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
            position: relative;
            cursor: pointer; /* 添加指针样式 */
        }

        .detail-image::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 40%;
            background: linear-gradient(to top, rgba(0, 0, 0, 0.1), transparent);
        }

        .detail-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .detail-image i {
            font-size: 3.5rem;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        #detailName {
            font-size: 1.4rem;
            font-weight: 700;
            margin-bottom: 8px;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        #detailDescription {
            color: var(--dark-light);
            font-size: 1rem;
            line-height: 1.6;
            margin-bottom: 20px;
        }

        .price-info {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            padding: 15px;
            background: rgba(255, 255, 255, 0.8);
            border-radius: 12px;
            border: 1px solid rgba(255, 107, 107, 0.2);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        }

        .detail-price {
            font-size: 1.8rem;
            font-weight: 800;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .detail-unit {
            font-size: 1rem;
            color: var(--dark-light);
        }

        .status-badge {
            background: linear-gradient(135deg, var(--success), #10ac84);
            color: white;
            padding: 8px 16px;
            border-radius: 20px;
            font-size: 0.9rem;
            font-weight: 600;
        }

        .book-btn {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            border: none;
            border-radius: 15px;
            padding: 16px;
            color: white;
            font-size: 1.1rem;
            font-weight: 700;
            width: 100%;
            transition: all 0.3s ease;
            box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .book-btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 30px rgba(255, 107, 107, 0.5);
            background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
        }

        .book-btn:active {
            transform: translateY(-1px);
        }

        /* 滚动条美化 */
        ::-webkit-scrollbar {
            width: 6px;
        }

        ::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.8);
            border-radius: 3px;
        }

        ::-webkit-scrollbar-thumb {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            border-radius: 3px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
        }

        /* 安全区域 */
        .safe-area {
            padding-bottom: env(safe-area-inset-bottom);
        }

        /* 响应式调整 */
        @media (max-width: 992px) {
            .product-list {
                grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
            }
        }

        @media (max-width: 768px) {
            .category-sidebar {
                width: 28%;
                max-width: 100px;
                padding: 15px 8px;
                top: 90px; /* 调整顶部间距 */
                height: calc(100vh - 90px); /* 调整高度 */
            }

            .product-area {
                padding: 15px;
            }

            .product-list {
                grid-template-columns: 1fr;
            }

            .product-card {
                padding: 16px;
            }

            .product-image {
                height: 140px;
            }
            
            .fixed-header {
                height: 90px; /* 减小高度 */
            }
            
            .main-container {
                padding-top: 90px; /* 减小顶部间距 */
            }
        }

        @media (max-width: 480px) {
            .club-header {
                padding: 10px 15px; /* 减小内边距 */
            }

            .club-logo {
                width: 36px; /* 减小尺寸 */
                height: 36px;
                font-size: 1.2rem; /* 减小字体大小 */
            }

            .club-name {
                font-size: 1.1rem; /* 减小字体大小 */
            }

            .announcement-bar {
                padding: 8px 12px; /* 减小内边距 */
            }
            
            .product-list {
                grid-template-columns: 1fr;
            }
            
            .fixed-header {
                height: 85px; /* 减小高度 */
            }
            
            .main-container {
                padding-top: 85px; /* 减小顶部间距 */
            }
            
            .category-sidebar {
                top: 85px; /* 调整顶部间距 */
                height: calc(100vh - 85px); /* 调整高度 */
            }
        }
        
        /* 美化提示框样式 */
        .custom-toast {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(255, 255, 255, 0.98);
            backdrop-filter: blur(20px);
            border: 1px solid rgba(255, 107, 107, 0.4);
            border-radius: 20px;
            padding: 30px;
            color: var(--dark);
            text-align: center;
            z-index: 9999;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
            animation: toastSlideIn 0.5s ease-out;
            max-width: 300px;
            width: 80%;
        }

        .custom-toast.hide {
            animation: toastSlideOut 0.5s ease-in forwards;
        }

        @keyframes toastSlideIn {
            0% {
                opacity: 0;
                transform: translate(-50%, -40%) scale(0.9);
            }
            100% {
                opacity: 1;
                transform: translate(-50%, -50%) scale(1);
            }
        }

        @keyframes toastSlideOut {
            0% {
                opacity: 1;
                transform: translate(-50%, -50%) scale(1);
            }
            100% {
                opacity: 0;
                transform: translate(-50%, -40%) scale(0.9);
            }
        }

        .toast-icon {
            font-size: 3.5rem;
            margin-bottom: 15px;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .toast-title {
            font-size: 1.4rem;
            font-weight: 700;
            margin-bottom: 10px;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .toast-message {
            font-size: 1rem;
            color: var(--dark-light);
            margin-bottom: 20px;
            line-height: 1.5;
        }

        .toast-button {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            border: none;
            border-radius: 12px;
            padding: 12px 24px;
            color: white;
            font-size: 1rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            width: 100%;
        }

        .toast-button:hover {
            background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
            transform: translateY(-2px);
        }

        /* 客服联系方式样式 */
        .contact-info {
            background: rgba(255, 255, 255, 0.8);
            border-radius: 12px;
            padding: 15px;
            margin: 15px 0;
            border: 1px solid rgba(255, 107, 107, 0.2);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        }

        .contact-item {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            padding: 8px 0;
            color: var(--dark);
        }

        .contact-item i {
            color: var(--primary);
            font-size: 1.1rem;
        }

        /* 遮罩层 */
        .toast-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(10px);
            z-index: 9998;
            animation: overlayFadeIn 0.3s ease-out;
        }

        .toast-overlay.hide {
            animation: overlayFadeOut 0.3s ease-in forwards;
        }

        @keyframes overlayFadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        @keyframes overlayFadeOut {
            from { opacity: 1; }
            to { opacity: 0; }
        }
        
        /* 新增动画效果 */
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }
        
        .pulse {
            animation: pulse 2s infinite;
        }
        
        /* 加载动画 */
        .loading-spinner {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 3px solid rgba(255,255,255,.3);
            border-radius: 50%;
            border-top-color: #fff;
            animation: spin 1s ease-in-out infinite;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        /* 图片查看器样式 */
        .viewer-container {
            z-index: 10000 !important;
        }
    </style>
</head>
<body>
    <!-- 顶部固定区域 -->
    <div class="fixed-header">
        <!-- 公告栏 -->
        <div class="announcement-bar">
            <div class="announcement-content">
                <i class="fas fa-bullhorn" style="color: var(--accent); margin-right: 12px;"></i>
                <span>🎯 新用户首单立减10元！组队下单享95折优惠！专属客服24小时在线服务！</span>
            </div>
        </div>
        
        <!-- 俱乐部标识 -->
        <div class="club-header">
            <div class="club-logo">
                <img src="/favicon.ico" alt="超英电竞" style="width: 100%; height: 100%; object-fit: cover; border-radius: 12px;">
            </div>
            <div class="club-name">超英电竞</div>
        </div>
    </div>
    
    <!-- 主容器 - 左右布局 -->
    <div class="main-container safe-area">
        <!-- 左侧分类导航 - 固定不滚动 -->
        <div class="category-sidebar">
            {volist name="categories" id="category" key="k"}
            <div class="category-item {if $k == 1}active{/if}" data-category="{$category.id}">
                {$category.name}
            </div>
            {/volist}
        </div>
        
        <!-- 右侧产品区域 -->
        <div class="product-area">
            <div class="product-list">
                {volist name="categories" id="category" key="cat_key"}
                    {if !empty($category['projects'])}
                        {volist name="category.projects" id="project"}
                        <div class="product-card" data-category="{$category.id}" style="display: {if $cat_key == 1}block{else}none{/if};">
                            <div class="product-image" onclick="previewImage(this)">
                                {if $project.image}
                                <img src="{$project.image}" alt="{$project.name}">
                                {else}
                                <i class="fas fa-gamepad"></i>
                                {/if}
                            </div>
                            
                            <h3 class="product-title">{$project.name}</h3>
                            <p class="product-desc">{$project.description}</p>
                            
                            <div class="product-meta">
                                <div class="price-container">
                                    <span class="product-price">¥{$project.default_price}</span>
                                    <span class="product-unit">/{$project.unit}</span>
                                </div>
                                <button class="product-btn" data-id="{$project.id}">
                                    <i class="fas fa-info-circle me-1"></i>详情
                                </button>
                            </div>
                        </div>
                        {/volist}
                    {/if}
                {/volist}
            </div>
        </div>
    </div>

    <!-- 详情模态框 -->
    <div class="modal fade detail-modal" id="projectDetailModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">服务详情</h5>
                    <button type="button" class="btn-close" onclick="closeModal()" aria-label="关闭"></button>
                </div>
                <div class="modal-body">
                    <div class="detail-image" onclick="previewImage(this)">
                        <img id="detailImage" src="" alt="" style="display: none;">
                        <i class="fas fa-image"></i>
                    </div>
                    
                    <h4 id="detailName" class="mb-2"></h4>
                    <p id="detailDescription" class="mb-3"></p>
                    
                    <div class="price-info">
                        <div>
                            <span class="detail-price" id="detailPrice"></span>
                            <span class="detail-unit" id="detailUnit"></span>
                        </div>
                        <span class="status-badge">可预约</span>
                    </div>
                    
                    <button class="book-btn" onclick="bookService()">
                        <i class="fas fa-calendar-check me-2"></i>立即预约
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!-- 在body底部添加Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/viewerjs/1.11.6/viewer.min.js"></script>
    <script>
        // 手动管理模态框状态
        let detailModal = null;
        
        // 显示模态框
        function showModal() {
            const modal = document.getElementById('projectDetailModal');
            modal.style.display = 'block';
            modal.classList.add('show');
            document.body.style.overflow = 'hidden';
            document.body.classList.add('modal-open');
            
            // 添加遮罩层
            const backdrop = document.createElement('div');
            backdrop.className = 'modal-backdrop fade show';
            document.body.appendChild(backdrop);
        }
        
        // 关闭模态框
        function closeModal() {
            const modal = document.getElementById('projectDetailModal');
            modal.style.display = 'none';
            modal.classList.remove('show');
            document.body.style.overflow = '';
            document.body.classList.remove('modal-open');
            
            // 移除遮罩层
            const backdrop = document.querySelector('.modal-backdrop');
            if (backdrop) {
                backdrop.remove();
            }
        }
        
        // 项目数据映射
        const projectData = {};
        
        // 页面加载完成后执行
        document.addEventListener('DOMContentLoaded', function() {
            // 从数据属性中提取项目信息
            document.querySelectorAll('.product-card').forEach(card => {
                const btn = card.querySelector('.product-btn');
                const projectId = btn.getAttribute('data-id');
                const title = card.querySelector('.product-title').textContent;
                const desc = card.querySelector('.product-desc').textContent;
                const price = card.querySelector('.product-price').textContent.replace('¥', '');
                const unit = card.querySelector('.product-unit').textContent.replace('/', '');
                const image = card.querySelector('.product-image img') ? card.querySelector('.product-image img').src : '';
                
                projectData[projectId] = {
                    name: title,
                    description: desc,
                    default_price: price,
                    unit: unit,
                    image: image
                };
            });
            
            // 分类切换
            document.querySelectorAll('.category-item').forEach(item => {
                item.addEventListener('click', function() {
                    document.querySelectorAll('.category-item').forEach(i => i.classList.remove('active'));
                    this.classList.add('active');
                    
                    const categoryId = this.getAttribute('data-category');
                    document.querySelectorAll('.product-card').forEach(card => {
                        card.style.display = card.getAttribute('data-category') === categoryId ? 'block' : 'none';
                    });
                });
            });
            
            // 详情按钮点击事件
            document.querySelectorAll('.product-btn').forEach(btn => {
                btn.addEventListener('click', function() {
                    const projectId = this.getAttribute('data-id');
                    showProjectDetail(projectId);
                });
            });
            
            // 点击遮罩层关闭模态框
            document.addEventListener('click', function(e) {
                if (e.target.classList.contains('modal-backdrop')) {
                    closeModal();
                }
            });
            
            // ESC键关闭模态框
            document.addEventListener('keydown', function(e) {
                if (e.key === 'Escape') {
                    closeModal();
                }
            });
            
            // 初始化图片查看器
            initImageViewer();
        });

        // 显示项目详情
        function showProjectDetail(projectId) {
            const project = projectData[projectId];
            if (!project) return;
            
            document.getElementById('detailName').textContent = project.name;
            document.getElementById('detailDescription').textContent = project.description;
            document.getElementById('detailPrice').textContent = '¥' + project.default_price;
            document.getElementById('detailUnit').textContent = '/' + project.unit;
            
            // 设置图片
            const detailImage = document.getElementById('detailImage');
            if (project.image && project.image !== '') {
                detailImage.src = project.image;
                detailImage.style.display = 'block';
                detailImage.nextElementSibling.style.display = 'none';
            } else {
                detailImage.style.display = 'none';
                detailImage.nextElementSibling.style.display = 'block';
            }
            
            showModal();
        }
        
        // 预约服务
        function bookService() {
            // 创建遮罩层
            const overlay = document.createElement('div');
            overlay.className = 'toast-overlay';
            document.body.appendChild(overlay);
            
            // 创建提示框
            const toast = document.createElement('div');
            toast.className = 'custom-toast';
            toast.innerHTML = `
                <div class="toast-icon">
                    <i class="fas fa-headset"></i>
                </div>
                <div class="toast-title">下单提示</div>
                <div class="toast-message">请联系客服下单</div>
                <div class="contact-info">
                    <div class="contact-item">
                        <i class="fas fa-phone"></i>
                        <span>客服电话: 保密保密</span>
                    </div>
                    <div class="contact-item">
                        <i class="fas fa-comment"></i>
                        <span>24小时在线客服</span>
                    </div>
                    <div class="contact-item">
                        <i class="fas fa-weixin"></i>
                        <span>微信: yQ04I9</span>
                    </div>
                </div>
                <button class="toast-button" onclick="closeToast()">
                    <i class="fas fa-check me-2"></i>我知道了
                </button>
            `;
            document.body.appendChild(toast);
            
            // 点击遮罩层也可以关闭
            overlay.addEventListener('click', closeToast);
            
            // 关闭详情模态框
            closeModal();
        }
        
        // 关闭提示
        function closeToast() {
            const toast = document.querySelector('.custom-toast');
            const overlay = document.querySelector('.toast-overlay');
            
            if (toast) {
                toast.classList.add('hide');
                setTimeout(() => toast.remove(), 500);
            }
            
            if (overlay) {
                overlay.classList.add('hide');
                setTimeout(() => overlay.remove(), 500);
            }
        }
        
        // 初始化图片查看器
        function initImageViewer() {
            // 为所有产品图片添加查看器
            const productImages = document.querySelectorAll('.product-image img');
            productImages.forEach(img => {
                img.addEventListener('click', function() {
                    previewImage(this.parentElement);
                });
            });
        }
        
        // 预览图片
        function previewImage(element) {
            const img = element.querySelector('img');
            if (!img || img.style.display === 'none') return;
            
            // 创建临时图片查看器
            const viewerDiv = document.createElement('div');
            viewerDiv.style.position = 'fixed';
            viewerDiv.style.top = '0';
            viewerDiv.style.left = '0';
            viewerDiv.style.right = '0';
            viewerDiv.style.bottom = '0';
            viewerDiv.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
            viewerDiv.style.display = 'flex';
            viewerDiv.style.alignItems = 'center';
            viewerDiv.style.justifyContent = 'center';
            viewerDiv.style.zIndex = '10000';
            viewerDiv.style.cursor = 'zoom-out';
            
            const viewerImg = document.createElement('img');
            viewerImg.src = img.src;
            viewerImg.style.maxWidth = '90%';
            viewerImg.style.maxHeight = '90%';
            viewerImg.style.objectFit = 'contain';
            viewerImg.style.borderRadius = '8px';
            
            viewerDiv.appendChild(viewerImg);
            document.body.appendChild(viewerDiv);
            
            // 点击关闭查看器
            viewerDiv.addEventListener('click', function() {
                document.body.removeChild(viewerDiv);
            });
            
            // ESC键关闭查看器
            document.addEventListener('keydown', function closeViewer(e) {
                if (e.key === 'Escape') {
                    document.body.removeChild(viewerDiv);
                    document.removeEventListener('keydown', closeViewer);
                }
            });
        }
    </script>
</body>
</html>